package ink.xiaobaibai.common;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

/**
 * @description: 服务员的房间对象
 * @author: 小白白
 * @create: 2021-07-26
 **/

@Setter
@Getter
@NoArgsConstructor
public class RoomObj {

    // 待检验,内部对象是否可以被检测到->可以对象的对象内加上 @Valid 注解
    public RoomObj(String room, Integer seconds, Integer count) {
        this.room = room;
        this.seconds = seconds;
        this.count = count;
    }

    public RoomObj(@NotNull String room) {
        this.room = room;
    }

    /**
     * 房间号
     */
    @NotNull
    private String room;

    /**
     * 一次启动的时间(秒)
     */
    @NotNull
    @Min(value = 1, message = "秒数最小不能为1")
    private Integer seconds;

    /**
     * 可以运行的次数
     */
    @NotNull
    @Min(value = 1, message = "运行次数最小不能为1")
    private Integer count;

    private transient boolean open;

    private transient String stopTime;

    @Override
    public int hashCode() {
        return this.room.hashCode();
    }

    @Override
    public boolean equals(Object obj) {
        return this.room.equals(((RoomObj) obj).room);
    }
}
